package com.ciaojian.core.service;


import com.ciaojian.core.model.User;
import com.ciaojian.core.util.SnowFlake;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;

@Service
public class BytePayService {

    public String getNewOrderNo(User User) {
        String prefix = new SimpleDateFormat("yyyyMMddHHmmsss").format(new Date());
//        int i = (int) (Math.random() * 900) + 100;
//        String s = Integer.toString(i);

        //获取自增 最后三位
        SnowFlake snowFlake = new SnowFlake(0, 0);
        long nextId = snowFlake.nextId();
        String str = Long.toString(nextId);
        String s = str.substring(str.length() - 3);

        return prefix.concat("U").concat(String.valueOf(User.getId())).concat(s);
    }
}
